package com.example.dao;

import com.example.entity.XueYuanInfo;
import com.example.entity.ZhuanYeInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 涛某
 * @version 1.0
 * @date 2024/3/26 9:27
 */
@Repository
public interface ZhuanyeInfoDao extends Mapper<ZhuanYeInfo> {

    @Select("select a.*,b.name as xueyuanname from zhuanye as a LEFT JOIN xueyuan as b on a.ssxy=b.id")
    List<ZhuanYeInfo> findAll();

    @Insert("insert into zhuanye (name,ximing,ssxy) values(#{name},#{ximing},#{ssxy})")
    void add(ZhuanYeInfo zhuanYeInfo);

    @Update("update zhuanye set name=#{name},ximing=#{ximing},ssxy=#{ssxy}")
    void update();
    @Delete("delete from zhuanye where id = #{id}")
    Long del(@Param("id") Long id);

    @Select("select  c.* from (select a.*,b.name as xueyuanname from zhuanye\n" +
            " as a LEFT JOIN xueyuan as b on a.ssxy=b.id) c  where c.xueyuanname like concat('%',#{search},'%') ")
    List<ZhuanYeInfo> search(@Param("search") String search);
}
